package com.eas.ereceipt.app;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.ExpandableListView.OnGroupClickListener;

import com.eas.ereceipt.R;
import com.eas.ereceipt.adapter.SlidingMenuAdapter;

public class SlidingMenuFragment extends Fragment {
	private ExpandableListView lvMenu;
	private SlidingMenuAdapter adapter;
	private OnGroupClickListener groupClickListener;
	private OnChildClickListener childClickListener;
	private OnClickListener headerClickListener;

	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		View root;
		root = inflater.inflate(R.layout.fragment_sliding_menu, container, false);
		
		lvMenu = (ExpandableListView) root.findViewById(R.id.lvSlidingMenu);
		
		adapter = new SlidingMenuAdapter(getActivity());
		
		View header = inflater.inflate(R.layout.header_menu, lvMenu, false);
		header.setOnClickListener(headerClickListener);
		
		lvMenu.addHeaderView(header);
		
		lvMenu.setAdapter(adapter);
		
		lvMenu.setOnGroupClickListener(groupClickListener);
		lvMenu.setOnChildClickListener(childClickListener);
		
		
		lvMenu.expandGroup(0);
		lvMenu.expandGroup(1);
		
		return root;
	}
	
	public void setClickListeners(OnClickListener headerClickListener, OnGroupClickListener groupClickListener, OnChildClickListener childClickListener){
		this.headerClickListener = headerClickListener;
		this.groupClickListener = groupClickListener;
		this.childClickListener = childClickListener;
	}

}
